/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.istia.gesstages.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

/**
 *
 * @author usrlocal
 */
@Entity
@Table(name = "candidatures", uniqueConstraints =
@UniqueConstraint(name = "candidature_unique", columnNames = {"ref_stageid", "ref_userid"}))
public class Apply implements Serializable {

    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @JoinColumn(name = "ref_stageid", nullable = false)
    @ManyToOne(fetch = FetchType.EAGER)
    private Offer stage;
    @JoinColumn(name = "ref_userid", nullable = false)
    @ManyToOne(fetch = FetchType.EAGER)
    private User user;
    @Column(name = "ref_date", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date date;

    public Apply() {
    }

    public Apply(Offer stage, User student, Date date) {
        this.stage = stage;
        this.user = student;
        this.date = date;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Offer getStage() {
        return stage;
    }

    public void setStage(Offer stage) {
        this.stage = stage;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
